﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace UI.Login
{
    /// <summary>
    /// AjaxHandler 的摘要说明
    /// </summary>
    public class AjaxHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var name = context.Request["name"];
            var pwd = context.Request["pwd"];
            var type = context.Request["type"];
            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(pwd))
            {
                context.Response.Write("账号或密码为空");
            }
            try
            {
                var cookie = new HttpCookie("UserInfo");
                cookie.Values["number"] = name;
                cookie.Values["pwd"] = pwd;
                cookie.Expires = DateTime.Now.AddDays(1);
                context.Response.AppendCookie(cookie);
                context.Response.Write("");
            }
            catch
            {
                context.Response.Write("Cookie存储失败！");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}